<?php
namespace App\Api\Controllers;
use Common\ApiController;
use Common\Models\NoticesIndex;
use Common\Models\Qcate;
use Common\Models\Questions;

class QuestionController extends ApiController
{
    protected $checkUser = false;
    protected $cache = true;
    protected $SignAuth = false;
	public function initialize()
	{
		parent::initialize();
	}


    /**
     * 问题列表页面
     */
    public function common_questionAction(){
        $qcate = new Qcate();
        $list_question = $qcate->findlist();
        $question = new Questions();
        foreach($list_question as $key=>$value){
            $list_question[$key]['child'] = $question->find_by_questionlist_cate($value['id'],0);
        }
        $this->view->setVars(
            [
                "data" => $list_question,
            ]
        );
    }


    /**
     * 问题列表
     */
    public function questqionlistAction(){
        $params = array_merge($this->request->get(),$this->request->getPost());
        if(!isset($params['cid']) || empty($params['cid'])){

        }
        $question = new Questions();
        $list = $question->find_by_questionlist_cate($params['cid'],10000);
        $this->view->setVars(
            [
                "data" => $list,
            ]
        );
    }


    /**
     * 问题详情
     */
    public function questqiondetailAction(){
        $params = array_merge($this->request->get(),$this->request->getPost());
        if(!isset($params['aid']) || empty($params['aid'])){

        }
        $question = new Questions();
        $info = $question->get_by_id($params['aid']);
        $this->view->setVars(
            [
                "info" => $info,
            ]
        );
    }

}
